package com.meiqiongproperty.yiguanjia.fragment.home.health;

import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.meiqiongproperty.yiguanjia.R;
import com.meiqiongproperty.yiguanjia.databinding.HealthyInfoLayoutBinding;
import com.meiqiongproperty.yiguanjia.fragment.BaseFragment;
import com.meiqiongproperty.yiguanjia.http.api.ApiService;
import com.meiqiongproperty.yiguanjia.http.interfaces.IHttpCallback;
import com.meiqiongproperty.yiguanjia.http.sendJsonModel.SendHealthyInfo;
import com.meiqiongproperty.yiguanjia.httpbean.healthy.HealthyInfoBean;
import com.meiqiongproperty.yiguanjia.utils.Utils;

/**
 * author: Administrator
 * date: 2017/6/11.
 * package:com.meiqiongproperty.yiguanjia.fragment.home.health
 */

public class HealthyInfoFragment extends BaseFragment {
    HealthyInfoLayoutBinding binding;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.healthy_info_layout, container, false);
        initView();
        return binding.getRoot();
    }

    public void initView() {
        getPersonalHealthyInfo();
        binding.navigation.setTitle("个人档案");
        binding.navigation.setLeftClick(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                sendKeyBackEvent();
            }
        });
    }

    /**
     * 获取个人档案记录数据
     */
    public void getPersonalHealthyInfo() {
        SendHealthyInfo info = new SendHealthyInfo();
        info.setToken(Utils.getToken(getActivity()));
        ApiService.getHealthyInfo(getActivity(), new IHttpCallback<HealthyInfoBean>() {
            @Override
            public void onNext(HealthyInfoBean healthyInfoBean) {
                binding.setHealthyInfo(healthyInfoBean);
            }

            @Override
            public void onError(int code, String message) {

            }
        }, Utils.getRequestBody(info));
    }
}
